﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class DangNhap : System.Web.UI.Page
{
    khachhang kh = new khachhang();
    protected void Page_Load(object sender, EventArgs e)
    {
        if (IsPostBack == false)
        {
            if (Session["kh"] == null)
                MultiView1.SetActiveView(View1);
            else
            {
                MultiView1.SetActiveView(View2);
                string cn = kh.Kiemtra_CN(Session["kh"].ToString());
                if (cn.ToString() != "CN01")
                {
                    linkbtnQL.Visible = true;
                    btnQL.Visible = true;
                }
            }
        }
    }

    protected void lbtnThoat_Click(object sender, EventArgs e)
    {
        Session.Abandon();
        Response.Redirect("TrangChu.aspx");

    }
    protected void lbtnThoat1_Click(object sender, EventArgs e)
    {
        Session.Abandon();
        Response.Redirect("DangNhap.aspx");
    }
    protected void lbtndoimk_Click(object sender, EventArgs e)
    {
        Response.Redirect("DoiMatKhau.aspx");
    }

    protected void LBT_DangKi_Click(object sender, EventArgs e)
    {
        Response.Redirect("DangKy.aspx");
    }
    protected void btnDangNhap_Click(object sender, ImageClickEventArgs e)
    {
        try
        {
            string ten = kh.dangnhap(txttendn.Text, txtmk.Text);
            Session["kh"] = ten;
            lblten.Text = ten;
            MultiView1.SetActiveView(View2);
            string cn = kh.Kiemtra_CN(Session["kh"].ToString());
            if (cn.ToString() != "CN01")
            {
                linkbtnQL.Visible = true;
                btnQL.Visible = true;
            }
        }
        catch (Exception ex)
        {

            lblthongbao.Text = ex.Message;
            MultiView1.SetActiveView(View1);
        }
    }
    protected void linkDN_Click(object sender, EventArgs e)
    {
        try
        {
            string ten = kh.dangnhap(txttendn.Text, txtmk.Text);
            Session["kh"] = ten;
            lblten.Text = ten;
            MultiView1.SetActiveView(View2);
            string cn = kh.Kiemtra_CN(Session["kh"].ToString());
            if (cn.ToString() != "CN01")
            {
                linkbtnQL.Visible = true;
                btnQL.Visible = true;
            }
        }
        catch (Exception ex)
        {

            lblthongbao.Text = ex.Message;
            MultiView1.SetActiveView(View1);
        }
    }
}